import java.util.concurrent.*;

/**
 * @author Jiange
 * @create 2021-05-13-16:33
 */

/**
 * ThreadPoolExecutor主要用这个类
 */
public class ThreadPoolDemo {
    public static void main(String[] args) {
//        ExecutorService executorService = Executors.newFixedThreadPool(5);
        ExecutorService executorService = Executors.newCachedThreadPool();//一池nge线程  可以扩容

        ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 5, 3l, TimeUnit.SECONDS, new LinkedBlockingDeque<>(3), Executors.defaultThreadFactory(), new ThreadPoolExecutor.CallerRunsPolicy());
        for (int i = 0; i < 10; i++) {
            executor.execute(()->{
                System.out.println(Thread.currentThread().getName()+"\t办理");
            });
        }
        executor.shutdown();
    }
}
